//这个模块对API接口进行统一管理
import requests  from "./request";
import mockrequests from './mockAjax'


//1.axios发送请求 /api地址获取真实数据
export const reqCategoryList=()=>{

    return requests({
        url:'/product/getBaseCategoryList',
        method:'get'
    })
} 


//2.mock发送虚拟请求bannner
export const reqgetBanner=()=>{
    //注意这里不能写/mock因为前面的baseURL中写了/mock
   return mockrequests({
    url:'/banner',
    method:'get'
})
} 


//3.mock发送虚拟请求floor
export const reqgetFloor=()=>{
    //注意这里不能写/mock因为前面的baseURL中写了/mock
   return mockrequests({
    url:'/floor',
    method:'get'
})
} 

//4.获取搜索模块数据post请求
//post发送请求给服务器传递至少为{}空对象(调用函数时)
export const reqgetSearch=(params)=>{
    return requests({url:'/list',method:'post',data:params})
}

//5.获取详情模块数据get请求/api/item/{ skuId }(detail)
export const reqGoodsInfo=(skuId)=>{
    return requests({url:`/item/${skuId}`,method:'get'})
}

//6.将商品添加到购物车中（包括获取更新商品信息）(detail)用两次
//  /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddshopCart=(skuId,skuNum)=>{
    return requests({url:`/cart/addToCart/${skuId}/${skuNum}`,method:'post'})
}

//7.获取购物车列表数据接口/cart/cartList
export const reqGetshopCart=()=>{
    return requests({url:'/cart/cartList',method:'get'})
}

//8.删除购物车列表数据接口/api/cart/deleteCart/{skuId}
export const reqDeleteCartbyId=(skuId)=>{
    return requests({url:`/cart/deleteCart/${skuId}`,method:'delete'})
}

//9.切换商品状态/api/cart/checkCart/{skuID}/{isChecked}
export const reqCheckedbyId=(skuId,isChecked)=>{
    return requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})
}

//10.获取验证码接口/api/user/passport/sendCode/{phone}
export const reqGetCode=(phone)=>{
    return requests({url:`/user/passport/sendCode/${phone}`,method:'get'})
}

//11.注册/api/user/passport/register
export const reqUserRegister=(data)=>{
    return requests({url:'/user/passport/register',data,method:'post'})
}

//12.登录/api/user/passport/login
export const reqUserLogin=(data)=>{
    return requests({url:'/user/passport/login',data,method:'post'})
}

//13.获取用户信息，通过token /api/user/passport/auth/getUserInfo
export const reqGetUserinfo=()=>{
    return requests({url:'/user/passport/auth/getUserInfo',method:'get'})
}

//14.用户退出 通过token /api/user/passport/logout
export const reqUserlogout=()=>{
    return requests({url:'/user/passport/logout',method:'get'})
}

// 15.获取用户地址 自己mock数据(失效)
export const reqAddressInfo=()=>{
    return mockrequests({
        url:'/address',
        method:'get'
    })
}
//16.获取订单交易信息  /api/order/auth/trade(失效)
export const reqGetorderInfo=()=>{
    return requests({url:'/order/auth/trade',method:'get'})
}

//17.提交订单信息  /api/order/auth/submitOrder?tradeNo={tradeNo}(失效)
export const reqsubmitOrder=(tradeNo,data)=>{
    return requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,data,method:'post'})
}

//18.获取订单支付状态接口  /api/payment/weixin/queryPayStatus/{orderId}(失效)
export const reqPaystate=(orderId)=>{
    return requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'post'})
}

//19.获取订单列表  /api/order/auth/{page}/{limit}(失效)
export const reqMyorderList=(page,limit)=>{
    return requests({url:`/order/auth/${page}/${limit}`,method:'get'})
}